<?php

class Test_model extends Model {
	
	
	var $id ;
	var $last_name;
	var $first_name;
	
	function test_model()
	{
		parent::Model();
	}
	
	function get() {
			
		// If any of the following properties are set before customers_model->get() is called from the controller
		//  then we will include a where statement for each of the properties that have been set.
        if ($this->id) {
            $this->db->where("id", $this->id);
        }

        if ($this->last_name) {
            $this->db->where("last_name", $this->last_name);
        }

        if ($this->first_name) {
            $this->db->where("first_name", $this->first_name);
        }

		
		
		$query = $this->db->get('test');
		if ($query->num_rows() > 0) {
			return $query->result_array();
		}
		else
			return FALSE;
	}

	function save()
	{
		// Allows you to add a new customer as well as update an existing customer
		
		$db_array = array(
			"last_name" => $this->last_name,
	        "first_name" => $this->first_name);
	        


        // If Customers_model->customer_id was set in the controller, then we will update an existing record.
        if ($this->id) {
            $this->db->where("id", $this->id);
            $this->db->update("test", $db_array);
        }

        // If Customers_model->customer_id was not set in the controller, then we will insert a new record.
        else {
            $this->db->insert("test", $db_array);
        }
    }	
}
?>
